package com.googlecode.grt192.HH11.actuator;

import com.googlecode.grtframework.rpc.RPCConnection;
import com.googlecode.grtframework.rpc.RPCMessage;

/**
 * An RPCSolenoidValve abstracts A hardware SolenoidValve through the rpc
 * interface
 * 
 * @author ajc
 * 
 */
public class RPCSolenoidValve implements ISolenoid {

	public static double DATA_ACTIVATED = 1.0;
	public static double DATA_DEACTIVATED = 0.0;

	private final RPCConnection conn;
	private final int rpcKey;

	/**
	 * 
	 * @param conn
	 *            connection to host listening for Solenoid commands
	 * @param rpcKey
	 *            key to send to host listening for solenoid commands
	 */
	public RPCSolenoidValve(RPCConnection conn, int rpcKey) {
		this.conn = conn;
		this.rpcKey = rpcKey;
	}

	@Override
	public void activate() {
		conn.send(new RPCMessage(rpcKey, DATA_ACTIVATED));
	}

	@Override
	public void deactivate() {
		conn.send(new RPCMessage(rpcKey, DATA_DEACTIVATED));
	}

}
